﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using SKYPE4COMLib;


namespace Model_SSResourceManager
{
    public class MessageSender
    {
        public bool SendToEmail(string emailAdress, string MessageTxt)
        {
            SmtpClient Smtp = new SmtpClient("smtp.gmail.com", 587);
            Smtp.Credentials = new NetworkCredential("ssrm.adm@gmail.com", "bca3a407");
            Smtp.EnableSsl = true;

            MailMessage Message = new MailMessage();
            Message.From = new MailAddress("<SSRM Message Sender> ssrm.adm@gmail.com");
            Message.To.Add(new MailAddress(emailAdress));
            Message.Subject = "SSRM Message";
            Message.Body = MessageTxt;

            try
            {
                Smtp.Send(Message);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public bool SendToSkype(string skypeName, string MessageTxt)
        {
            Skype skype_machine;
            skype_machine = new Skype();

            try
            {
                if (!skype_machine.Client.IsRunning)
                {
                    skype_machine.Client.Start(true, true);
                }

                skype_machine.Attach(6, true);
                skype_machine.SendMessage(skypeName, MessageTxt);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
            
        }
    }
}
